/******FIGURE A.II: EFFECTS ON VOTER REGISTRATION (2002-2016) ***********/

/*******RUN ANALYSIS**********/
use ../data/main_extended.dta, clear
global fixed_effects "cb pop_dec#elec_id CBG#elec_id"

sum reg if tau_extended==-1
local m = round(r(mean), .01)

eventdd reg all, timevar(tau_extended)   ///
	absorb( $fixed_effects ) hdfe tolerance(0.0001) cluster(CBG) ///
	ci(rcap) ci_op(fcolor(gs10%30) lcolor(gs10))
	parmest, label saving (../estimates/figA2_extended, replace)

outreg2 using ../output/table_extended.xls, append stats(coef se) ctitle(`y') dec(3) addtext(mean, `m') alpha(.01, .05, .10) symbol(***, **, *) excel side


/*******CREATE FIGURES*********/
local file = "figA2_extended"
use ../estimates/`file', clear

local lower = -10
local upper = 20
local lower1 = `lower'-2.5
local upper1 = `upper'+2.5
local increment = 5

local tsize = "medlarge"
local labsize = "medium"
local titlesize = "vlarge"
local mcolor = "black"
local lcolor = "gs5"

gen time = real(substr(parm, -1, 1))
replace time = time*-1 if strpos(parm, "lag")==0

drop if time==.

expand 2 if time==-2, gen(omit)
replace time = -1 if omit
replace estimate = 0 if omit
replace min95 = 0 if omit
replace max95 = 0 if omit

graph twoway (scatter estimate time, mcolor(`mcolor')) (rcap min95 max95 time, lcolor(`lcolor')), ///
	xline(-.5, lcolor(red)) yline(0, lcolor(gs5)) ///
	ylabel(`lower'(`increment')`upper', grid labsize(`labsize')) yscale(range(`lower1' `upper1')) ///
	xlabel(-7(1)6) xscale(range(-7 6)) ///
	ytitle("Registrations", size(`tsize')) ///
	xtitle("Elections to Killing", size(`tsize')) ///
	legend(off) plotregion(fcolor(white)) graphregion(fcolor(white) lwidth(large) lcolor(white)) bgcolor(white)
	graph export ../output/`file'.png, replace
	graph export ../output/`file'.eps, replace
	
